另類的[分頁顯示效果]?!

穩萊
另類的[分頁顯示效果]?!
什麼都不做,就是查詢數據,一頁顯示多少條就查詢多少條數據出來。這樣的速度應該是很快的了吧?哈哈。。思路就是,給ID值出來,使用此ID值做下一頁或上一頁的查詢條件,並且還要排序!!在這裡查詢結果排序也起了很重要的作用!!!!示例代碼如下:
<!--#include file="Conn.asp"-->
<%
Dim aFlag,NowID,LastID,iShowNum
iShowNum=20                   '一頁顯示多少條記錄
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>無標題文檔</title>
<style type="text/css">
<!--
td {
 font-family: "細明體";
 font-size: 12px;
}
a:link {
 font-family: "細明體";
 font-size: 12px;
 color: #999999;
 text-decoration: none;
}
a:visited {
 font-family: "細明體";
 font-size: 12px;
 color: #999999;
 text-decoration: none;
}
a:active {
 font-family: "細明體";
 font-size: 12px;
 color: #999999;
 text-decoration: none;
}
a:hover {
 font-family: "細明體";
 font-size: 12px;
 color: #FF9900;
 text-decoration: underline;
}
-->
</style>
</head>

<body>
<table width="750"  border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#D5D5D5">
  <tr bgcolor="#F3F3F3">
    <td width="10%" height="25" bgcolor="#F3F3F3"><div align="center"><strong>序號</strong></div></td>
    <td width="25%" height="25"><div align="center"><strong>電影名稱</strong></div></td>
    <td width="57%" height="25" bgcolor="#F3F3F3"><div align="center"><strong>電影URL地址</strong></div></td>
    <td width="8%" height="25"><div align="center"><strong>類型</strong></div></td>
  </tr>
<%
Call Show_List
%>
  <tr bgcolor="#F3F3F3">
    <td height="20" colspan="4"><div align="right"><a href="Index.asp?aFlag=Fir">[首頁]</a>&nbsp;&nbsp;<a href="Index.asp?aFlag=Pre&sID=<%=NowID%>">[上一頁]</a>&nbsp;&nbsp;<a href="Index.asp?aFlag=Nex&sID=<%=LastID%>">[下一頁]</a>&nbsp;&nbsp;<a href="Index.asp?aFlag=End">[尾頁]</a></div></td>
  </tr>
</table>
</body>
</html>
<%
Call CloseDatabase

Sub Show_List
Dim LastFlag,NowFlag
Dim ArrayRow
 aFlag=Request("aFlag")
 NowID=Request("sID")
 Select Case aFlag
        Case "Nex"
          If NowID<>"" Then
             Sql="Select Top "&iShowNum&" Id,Name,Url,Type From [Movie] Where ID>"&NowId&" order By ID Asc"
    Else
       Sql="Select Top "&iShowNum&" Id,Name,Url,Type From [Movie] order By ID Desc"
    End If
     Case "Pre"
          If NowID<>"" Then
             Sql="Select Top "&iShowNum&" Id,Name,Url,Type From [Movie] Where ID<"&NowId&" order By ID Desc"
    Else
       Sql="Select Top "&iShowNum&" Id,Name,Url,Type From [Movie]"
    End If
     Case "End"
          Sql="Select Top "&iShowNum&" Id,Name,Url,Type From [Movie] order By ID Desc"
     Case Else
          Sql="Select Top "&iShowNum&" Id,Name,Url,Type From [Movie]"
 End Select
 Set Rs=Conn.Execute(Sql)
 LastFlag=False
 NowFlag=False
 If Rs.Eof Then
    Rs.Close
    Set Rs=Nothing
    Exit Sub
 End If
 '獲取數據到一個二維數組
 ArrayRow=Rs.GetRows()
 Dim iFrom,iTo,iStep
 If aFlag="Pre" or aFlag="End" Then
    iFrom=Ubound(ArrayRow,2)
    iTo=0
    iStep=-1
 Else
    iFrom=0
    iTo=Ubound(ArrayRow,2)
    iStep=1
 End If
 NowID=ArrayRow(0,iFrom)
 LastID=ArrayRow(0,iTo)
 For i=iFrom To iTo Step iStep
    Response.Write " <tr bgcolor=""#FDFDFD"" style=""cursor:hand"" onmouseover=""this.style.background='#F3F3F3'"" onmouseout=""this.style.background='#FDFDFD'"">"
    Response.Write "    <td height=""20""><div align=""center"">"&ArrayRow(0,i)&"</div></td>"
    Response.Write "    <td>"&ArrayRow(1,i)&"</td>"
    Response.Write "    <td>"&ArrayRow(2,i)&"</td>"
    Response.Write "    <td>"&ArrayRow(3,i)&"</td>"
    Response.Write "  </tr>"
    Next
 Rs.Close
 Set Rs=Nothing
End Sub
%>

 給當前日誌評分:
Loading Vote
正在讀取評分資料...


文章來自: Tank部落格
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相關日誌:

評論: 0 | 引用: 0 | 查看次數: -
發表評論
暱 稱:
密 碼: 遊客發言不需要密碼.
內 容:
驗證碼: 驗證碼
選 項:
雖然發表評論不用註冊,但是為了保護您的發言權,建議您註冊帳號.